package springInvoke.feignface;
import java.util.ArrayList;
import java.util.List;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name="first-service-provider",fallback = PersonClient.PersonClientFallBack.class) //声明调用的服务名称  
public interface PersonClient {
	@RequestMapping(method = RequestMethod.GET,value = "/provide/person/{name}")
	public String person(@PathVariable String name,@RequestParam int age);
 
	@RequestMapping(method = RequestMethod.GET,value = "/provide/persons")
	public List<String> persons(@RequestParam String[] names);
	
	@Component
	public class PersonClientFallBack implements PersonClient{
		@Override
		public String person(String name, int age) {
			return "return one person error";
		}
		@Override
		public List<String> persons(String[] names) {
			List<String> list = new ArrayList<>();
			list.add("errors");
			return list;
		}
		
	}

}
